home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / New Venus / src / EventHandlers.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-05  |  1.3 KB  |  48 lines  |  [TEXT/CWIE]

  1. /*
  2.  ***********************************************************************
  3.  *
  4.  *
  5.  *                        Event Handler Classes
  6.  *                            Implementation
  7.  *        
  8.  *
  9.  ***********************************************************************
  10.  */
  11.  
  12. #include "EventHandlers.h"
  13. #include "window.h"
  14. #include "mymenv.h"
  15.  
  16. #if 0
  17.                                     // Pointer to a null event handler on the top
  18.                                     // of the chain of registered handlers.
  19.                                     // For now we don't have a chain, actually
  20.                                     // so this points to the only one event handler,
  21.                                     // or nil
  22. NullEventHandler * NullEventHandler::first_handler = nil;
  23. #endif
  24.  
  25.                 // Event handling loop. Returns only when the
  26.                 // WindowObject is to be destroyed
  27.                 // Performs a very basic dispatching of a received event
  28. void EventHandler::loop(void)
  29. {
  30.   for(;;)
  31.   {
  32.     if( !WaitNextEvent(everyEvent, &the_event, event_timeout, nil) )
  33.      if( serviced_window.handle_null_event(the_event.when) )
  34.        continue;
  35.      else
  36.        return;                // Null event handler decided it's time to quit
  37.  
  38.      if( the_event.what == kHighLevelEvent )
  39.      {
  40.        //do_well( AEProcessAppleEvent(&the_event) ); // are Apple events
  41.        continue;
  42.      }
  43.      
  44.      if( !serviced_window.handle_event(the_event) )
  45.        return;                // The handler decided it doesn't want any more events
  46.    }
  47. }
  48.